<include file="public@header"/>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input class="layui-input" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
<script type="text/html" id="files-item-tpl">
    <li id="saved-file{id}">
        <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
        <input class="layui-input" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
               style="width: 200px;" title="文件名称">
        <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
        <a href="javascript:uploadOne('附件上传','#file-{id}','file');">替换</a>
        <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>
<div class="layui-fluid js-check-wrap">
    <div class="layui-card">
        <div class="layui-card-header">编辑会员</div>

        <form action="{:url('AdminIndex/editPost')}" method="post" class="layui-form js-ajax-form" data-replace="1">
            <div class="layui-card-body">
                <div class="layui-tab">
                    <ul class="layui-tab-title">
                        <li class="layui-this">
                            <span class="icon-wrapper"><i class="fa fa-align-center"></i></span>
                            <span class="text-wrapper">编辑会员</span>
                        </li>
                    </ul>

                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-card-body">
                                <!-- 昵称 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">昵称</label>
                                    <div class="layui-input-block">
                                        <input type="hidden" name="post[id]" value="{$post.id}">
                                        <input class="layui-input form-replace" type="text" id="title" name="post[user_login]"
                                                value="{$post.user_login}"  data-field="article_title" readonly />
                                    </div>
                                </div>

                                <!-- 联系电话 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">联系电话</label>
                                    <div class="layui-input-block">
                                        <input class="layui-input form-replace" type="text" name="post[mobile]"
                                                value="{$post.mobile}"  data-field="article_title" readonly/>
                                    </div>
                                </div>

                                <!-- 相关部门 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">相关部门</label>
                                    <div class="layui-input-block">
                                        <input class="layui-input form-replace" type="text" name="post[department]"
                                                value="{$post.department}"  data-field="article_title" readonly/>
                                    </div>
                                </div>

                                <!-- 所属类型 -->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">所属角色</label>
                                    <div class="layui-input-block">
                                        <input class="layui-input form-replace" type="text" name="post[tagname]"
                                                value="{$post.tagname}"  data-field="article_title" readonly/>
                                    </div>
                                </div>
                            </div>
                        </div>
        
                        <div class="layui-tab-item">
                            <div class="layui-card-body">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">{:lang('PAGE_TITLE')}</label>
                                    <div class="layui-input-block">
                                        <input class="layui-input form-replace" type="text" name="post[page_title]"
                                               value="{$post['page_title']}" id="keywords" data-field="page_title" placeholder="{:lang('PLEASE_ENTER')}{:lang('PAGE_TITLE')}">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">{:lang('PAGE_KEYWORDS')}</label>
                                    <div class="layui-input-block">
                                        <input class="layui-input form-replace" type="text" name="post[page_keywords]"
                                               value="{$post['page_keywords']}" id="keywords" data-field="page_keywords" placeholder="{:lang('PLEASE_ENTER')}{:lang('PAGE_KEYWORDS')}">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">{:lang('PAGE_DESCRIPTION')}</label>
                                    <div class="layui-input-block">
                                        <textarea class="layui-textarea form-replace" name="post[page_description]" rows="5" data-field="page_description"
                                                  placeholder="{:lang('PLEASE_FILL_IN')}{:lang('PAGE_DESCRIPTION')}">{$post.page_description}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item padding-left-25">
                    <div class="layui-input-block">
                        <!-- <button type="button" class="layui-btn layui-btn-normal" onclick="CheckSenSubmit();" id="add-key">{:lang('SAVE')}</button>
                        <button type="submit" class="layui-btn layui-btn-normal js-ajax-submit" style="display:none;" id="js-ajax-submit">{:lang('SAVE')}</button> -->
                        <!-- <button type="button" class="layui-btn layui-btn-normal content-preview" onclick="contentPreview(editorcontent,'title','published_time');" id="add-key">{:lang('PREVIEW')}</button> -->
                        <a class="layui-btn layui-btn-primary" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                    </div>
                </div>
                    
            </div>
        </form>
    </div>
</div>

<include file="public@footer"/>
<include file="admin@theme/scripts"/>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.js"></script>
<script type="text/javascript">
    $(function () {
        if( $('#detail_content').length ){
            // $('.content-preview').show();
            UE.getEditor('detail_content');
        }

        if( $('#post_excerpt').length ){
            UE.getEditor('post_excerpt');
        }
        

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

        $('#more-template-select').val("{$post.more.template|default=''}");
    });

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('AdminCategory/select')}?operate=edit&ids=" + selectedCategoriesId, '请选择分类', {
            area: ['700px', '400px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择分类');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
</script>

